package com.huonan.service.itemservice.service;

import com.huonan.service.itemservice.domain.Item;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author huonan
 * @date 2020/2/27 16:15
 * @desc
 */
@Service
public class ItemService {
    private static final Map<Integer, Item> map = new HashMap<>();

    //创建假数据
    static {
        map.put(1, new Item(1, "商品3", "描述3 ItemB", "http://localhost/pic/pic1"));
        map.put(2, new Item(2, "商品4", "描述4 ItemB", "http://localhost/pic/pic2"));
    }

    //为Controller层提供查询数据的方法
    public Item queryItemById(int id) {
        return map.get(id);
    }
}
